package mshop.com.schild_kotlin.mvp.presenter

import android.content.Context
import mshop.com.schild_kotlin.base.applySchedulers
import mshop.com.schild_kotlin.entitys.SearchBean
import mshop.com.schild_kotlin.mvp.base.BaseContract
import mshop.com.schild_kotlin.mvp.base.BasePresenter
import mshop.com.schild_kotlin.mvp.model.SearchModel
import mshop.com.schild_kotlin.network.MyObserver

/**
 * Created by mayi on 2018/5/28.
 * @Autor CaiWF
 * @Email 401885064@qq.com
 * @TODO
 */
class SearchPresenter(val mContext:Context,val view:BaseContract.View<SearchBean>) : BasePresenter,BaseContract.Presenter{
    val mModel:SearchModel by lazy {
        SearchModel()
    }

    override fun requestData() {

    }

    override fun start() {
    }

    fun searchKey(key:String,start:Int){
      mContext?.let {
          mModel.loadData(start,key,it).applySchedulers().subscribe(object:MyObserver<SearchBean>(it){
              override fun onNext(t: SearchBean?) {
                  if (t != null) {
                      view.setData(t)
                  }
              }

          })

      }
    }

}